﻿using System;
using System.Globalization;
using ZYing.LiquidThemeEngine.Paginating;

namespace ZYing.LiquidThemeEngine
{
    /// <summary>
    ///     Liquid主题常量定义
    /// </summary>
    public static class Constants
    {
        public const string TemplateExtension = ".liquid";
        public const string DefaultLayout = "theme";
        public const int DefaultPageSize = 20;
        public const int MaxPageSize = 50;
        public const int MinPageSize = 5;
        public const string TranslationFilterDefaultArgumentName = "def";

        public static class ObjectNames
        {
            public const string Template = "template";
            public const string Paginate = "paginate";
            public const string Section = "section";
        }

        public static class AmbientNames
        {
            private const string Prefix = "$$";
            public const string LiquidThemeEngineOptions = Prefix + "LiquidThemeEngineOptions";
            public const string Layout = Prefix + "Layout";
            public const string Body = Prefix + "Body";
            public const string Theme = Prefix + "Theme";
            public const string Setting = Prefix + "Setting";
            public const string IndexContent = Prefix + "IndexContent";

            public static string GetLocaleDictionaryKey(CultureInfo culture)
            {
                return Prefix + "LocaleDictionary:" + culture;
            }

            public static string GetPaginationDataKey(IPaginationSource source, int pageSize)
            {
                if (source == null) throw new ArgumentNullException(nameof(source));
                return $"{Prefix}Pagination({source.GetHashCode()},{pageSize})";
            }

            public static string GetSectionSchemaKey(String section)
            {
                return $"{Prefix}SectionSchema@{section}";
            }
            public static string GetContentKey(string path)
            {
                return $"{Prefix}GetContentAsync@{path}";
            }
            public static string GetFileVersionKey(string path)
            {
                return $"{Prefix}GetFileVersion@{path}";
            }
            public static string GetTemplateKey(string path)
            {
                return $"{Prefix}GetTemplate@{path}";
            }
            public static string GetSlotContentKey(string name)
            {
                return $"{Prefix}SlotContent@{name}";
            }
        }

        public static class Directories
        {
            public const string Templates = "templates";
            public const string Snippets = "snippets";
            public const string Locales = "locales";
            public const string Layout = "layout";
            public const string Assets = "assets";
            public const string Config = "config";
            public const string Sections = "sections";
        }

        public static class Config
        {
            public const string SettingsData = "settings_data.json";
            public const string SettingsSchema = "settings_schema.json";
            public const string SettingsPreset = "settings_preset.json";
        }
    }
}